// JavaScript Document
//Generate Random Number
function addUser(){
	ho=document.getElementById('ho').value;
	ten=document.getElementById('ten').value;
	email=document.getElementById('email').value;
	matKhau=document.getElementById('matKhau').value;
	gioiTinh=document.getElementById('gioiTinh').value;
	ngay=document.getElementById('ngay').value;
	thang=document.getElementById('thang').value;
	nam=document.getElementById('nam').value;
	dienThoai=document.getElementById('dienThoai').value;
		//
	check	= true;
	if(check==true){		
		pos			= "results";
		loading		= "loading"
		xmlHttp 	= GetXmlHttpObject();

		if (xmlHttp == null) {
			alert("Your browser does not support AJAX!");
			return;
		}
		var url = "../controllers/controller-user.php?action=add&ho="+ho+"&ten="+ten
					+"&email="+email+"&matKhau="+matKhau+"&gioiTinh="+gioiTinh+"&ngay="+ngay+"&thang="+thang+"&nam="+nam+"&dienThoai="+dienThoai;
		url=url+"&id="+Math.random();
		//alert("test");
		xmlHttp.onreadystatechange = function () {
			document.getElementById(loading).innerHTML = LOADING_SMALL;
			if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
				document.getElementById(pos).innerHTML 		= xmlHttp.responseText;
				document.getElementById(loading).innerHTML	= "";
			}
		};
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
}

var LOADING_SMALL	='<img id="loading-small" src="../images/loading-small.gif" />';
//-------------------------------
var xmlHttp;
function GetXmlHttpObject() {
	var xmlHttp = null;
	try {
	  // Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	}
	catch (e) {
	  // Internet Explorer
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}